#include<iostream>
#include<unordered_map>
#include<vector>
#include<unordered_set>
#include<algorithm>
#include<map>
using namespace std;


void solve()
{
	string s; cin >> s;
	int l = 0, r = 3;
	unordered_map<int, unordered_map<int, int>> ma;
	int flag = 0;
	while (r < s.size())
	{
		if (s[l] == '1' && s[l + 1] == '1' && s[l + 2] == '0' && s[r] == '0')
		{
			ma[l][r] = 1;
			flag += 1;
		}
		l += 1; r += 1;
	}
	int q; cin >> q;
	while (q--)
	{
		int a, b; cin >> a >> b;
		if (s.size() < 4)
		{
			cout << "NO" << endl;
		}
		else
		{
			s[a - 1] = b + '0';
			for (int i = max(a - 4, 0); i <= a - 1 && i + 3 < s.size(); i++)
			{
				if (s[i] == '1' && s[i + 1] == '1' && s[i + 2] == '0' && s[i + 3] == '0')
				{
					if (!ma[i][i + 3]) flag += 1;
					ma[i][i + 3] = 1;
				}
				else
				{
					if (ma[i][i + 3] == 1) flag -= 1;
					ma[i][i + 3] = 0;
				}
			}
			if (!flag) cout << "NO" << endl;
			else cout << "YES" << endl;
		}
	}
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int t; cin >> t;
	while (t--)
	{
		solve();
	}
	return 0;
}
